
pkgname=coreutils
pkgver=8.29
pkgrel=1
pkgdesc="The basic file, shell and text manipulation utilities of the GNU operating system"
arch=('x86_64')
license=('GPL3')
url="https://www.gnu.org/software/coreutils"
groups=('base')
depends=('glibc' 'pam' 'acl' 'gmp' 'libcap')
source=("https://ftp.gnu.org/gnu/coreutils/${pkgname}-${pkgver}.tar.xz")
md5sums=('960cfe75a42c9907c71439f8eb436303')

build() {
  cd ${pkgname}-${pkgver}

  ./configure --prefix=/usr --libexecdir=/usr/lib \
              --enable-no-install-program=groups,hostname,kill,uptime
  make
}

check() {
  cd ${pkgname}-${pkgver}
  # one fail: FAIL tests/df/df-symlink.sh (exit status: 1) 
  make RUN_EXPENSIVE_TESTS=no check
}

package() {
  cd ${pkgname}-${pkgver}
  make DESTDIR=${pkgdir} install

  cd ${pkgdir}/usr/bin
  install -dm755 ${pkgdir}/bin
  # makepkg requirement
  ln -s /usr/bin/du ${pkgdir}/bin/du
  # binaries required by FHS
  _fhs=('cat' 'chgrp' 'chmod' 'chown' 'cp' 'date' 'dd' 'df' 'echo' 'false'
        'ln' 'ls' 'mkdir' 'mknod' 'mv' 'pwd' 'rm' 'rmdir' 'stty' 'sync'
        'true' 'uname')
  for i in ${_fhs[@]}; do
    ln -s ../usr/bin/$i ${pkgdir}/bin/$i
  done
}
